Skip to main content

Starting the Apache webserver

To install and start a web server, you can use Apache, one of the most widely used web server software on Linux systems(installing web server in different linux distros may different we use debian based ubuntu for our example). Here are the steps to install and start Apache on ubuntu :

Step 1: Update Package Lists

Before installing any software, it's a good practice to update the package lists to ensure you're installing the latest versions available:

sudo apt-get update

Step 2: Install Apache

You can install Apache using the apt-get package manager:

sudo apt-get install apache2

Step 3: Start Apache

Once the installation is complete, you can start the Apache web server using the following command:

sudo systemctl start apache2

Step 4: Enable Auto-Start on Boot (Optional)

To ensure that Apache starts automatically when your server boots up, you can enable it:

sudo systemctl enable apache2

Step 5: Check Apache Status

You can verify whether Apache is running correctly by checking its status:

sudo systemctl status apache2

You should see output indicating that Apache is active and running.

Step 6: Testing Apache

To test Apache, open a web browser and enter your server's IP address or hostname. You can find your server's IP address using the ifconfig command:

ifconfig

Look for the "inet" address associated with your primary network interface (e.g., eth0 or enp0s3).

In the web browser, type the IP address or hostname. You should see the default Apache welcome page, indicating that Apache is working correctly.

The default document root directory for Apache on Ubuntu is /var/www/html. You can place your web files in this directory or configure virtual hosts to host multiple websites on the same server.

You've successfully installed and started the Apache web server on your Ubuntu system.